const DEVICE_USER_AGENT_REGEXP = {
  ANDROID: /Linux|Android/gi,
  IOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/
}

export const detectDeviceType = () =>
    Object
        .keys(DEVICE_USER_AGENT_REGEXP)
        .find(key => DEVICE_USER_AGENT_REGEXP[key].test(navigator.userAgent));

// 是否是移动端
export function isMobile() {
  const userAgentInfo = navigator.userAgent;
  const agents = ["Android", "iPhone", "iPad"];
  let flag = false;
  for (let i = 0; i < agents.length; i++) {
    if (userAgentInfo.indexOf(agents[i]) > 0) {
      flag = true;
      break;
    }
  }
  return flag;
}
